<?php
/**
 * AsinComponentResponse
 *
 * PHP version 5
 *
 * @category Class
 * @package  AmazonAdvertisingApi
 * @author   vv_guo
 * @link    https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 */

/**
 * Sponsored Brands campaign management
 *
 * Create and manage Sponsored Brands campaigns.   To learn more about Sponsored Brands campaigns, see:   - [Sponsored Brands overview](guides/sponsored-brands/overview)  - [Sponsored Brands campaign structure](guides/sponsored-brands/campaigns/structure)  - [Get started with Sponsored Brands campaigns](guides/sponsored-brands/campaigns/get-started-with-campaigns)
 *
 * OpenAPI spec version: 4.0
 * 
 * Generated by:https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api.git
 * AmazonAdvertisingApi Codegen version: 3.0.51
 */
/**
 * NOTE: This class is auto generated by the AmazonAdvertisingApi code generator program.
 *https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 * Do not edit the class manually.
 */

namespace AmazonAdvertisingApi\Model;

use \ArrayAccess;
use \AmazonAdvertisingApi\ObjectSerializer;

/**
 * AsinComponentResponse Class Doc Comment
 *
 * @category Class
 * @description Pre-moderation result for an Asin component
 * @package  AmazonAdvertisingApi
 * @author   vv_guo
 * @link    https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 */
class AsinComponentResponse implements ModelInterface, ArrayAccess
{
    const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $AmazonAdvertisingApiModelName = 'AsinComponentResponse';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $AmazonAdvertisingApiTypes = [
        'pre_moderation_status' => 'string',
        'component_type' => 'string',
        'policy_violations' => '\AmazonAdvertisingApi\Model\AsinPolicyViolation[]',
        'asin' => 'string',
        'id' => 'string'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $AmazonAdvertisingApiFormats = [
        'pre_moderation_status' => null,
        'component_type' => null,
        'policy_violations' => null,
        'asin' => null,
        'id' => null
    ];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function AmazonAdvertisingApiTypes()
    {
        return self::$AmazonAdvertisingApiTypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function AmazonAdvertisingApiFormats()
    {
        return self::$AmazonAdvertisingApiFormats;
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'pre_moderation_status' => 'preModerationStatus',
        'component_type' => 'componentType',
        'policy_violations' => 'policyViolations',
        'asin' => 'asin',
        'id' => 'id'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'pre_moderation_status' => 'setPreModerationStatus',
        'component_type' => 'setComponentType',
        'policy_violations' => 'setPolicyViolations',
        'asin' => 'setAsin',
        'id' => 'setId'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'pre_moderation_status' => 'getPreModerationStatus',
        'component_type' => 'getComponentType',
        'policy_violations' => 'getPolicyViolations',
        'asin' => 'getAsin',
        'id' => 'getId'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$AmazonAdvertisingApiModelName;
    }

    const PRE_MODERATION_STATUS_REJECTED = 'REJECTED';
    const PRE_MODERATION_STATUS_APPROVED = 'APPROVED';
    const PRE_MODERATION_STATUS_FAILED = 'FAILED';
    const PRE_MODERATION_STATUS_RETRYABLE_FAILURE = 'RETRYABLE_FAILURE';
    const COMPONENT_TYPE_LANDING_ASIN = 'LANDING_ASIN';
    const COMPONENT_TYPE_PRODUCT_ASIN = 'PRODUCT_ASIN';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getPreModerationStatusAllowableValues()
    {
        return [
            self::PRE_MODERATION_STATUS_REJECTED,
            self::PRE_MODERATION_STATUS_APPROVED,
            self::PRE_MODERATION_STATUS_FAILED,
            self::PRE_MODERATION_STATUS_RETRYABLE_FAILURE,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getComponentTypeAllowableValues()
    {
        return [
            self::COMPONENT_TYPE_LANDING_ASIN,
            self::COMPONENT_TYPE_PRODUCT_ASIN,
        ];
    }

    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['pre_moderation_status'] = isset($data['pre_moderation_status']) ? $data['pre_moderation_status'] : null;
        $this->container['component_type'] = isset($data['component_type']) ? $data['component_type'] : null;
        $this->container['policy_violations'] = isset($data['policy_violations']) ? $data['policy_violations'] : null;
        $this->container['asin'] = isset($data['asin']) ? $data['asin'] : null;
        $this->container['id'] = isset($data['id']) ? $data['id'] : null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        $allowedValues = $this->getPreModerationStatusAllowableValues();
        if (!is_null($this->container['pre_moderation_status']) && !in_array($this->container['pre_moderation_status'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'pre_moderation_status', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        $allowedValues = $this->getComponentTypeAllowableValues();
        if (!is_null($this->container['component_type']) && !in_array($this->container['component_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'component_type', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets pre_moderation_status
     *
     * @return string
     */
    public function getPreModerationStatus()
    {
        return $this->container['pre_moderation_status'];
    }

    /**
     * Sets pre_moderation_status
     *
     * @param string $pre_moderation_status The pre-moderation status of the component.
     *
     * @return $this
     */
    public function setPreModerationStatus($pre_moderation_status)
    {
        $allowedValues = $this->getPreModerationStatusAllowableValues();
        if (!is_null($pre_moderation_status) && !in_array($pre_moderation_status, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'pre_moderation_status', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['pre_moderation_status'] = $pre_moderation_status;

        return $this;
    }

    /**
     * Gets component_type
     *
     * @return string
     */
    public function getComponentType()
    {
        return $this->container['component_type'];
    }

    /**
     * Sets component_type
     *
     * @param string $component_type Type of Asin component.
     *
     * @return $this
     */
    public function setComponentType($component_type)
    {
        $allowedValues = $this->getComponentTypeAllowableValues();
        if (!is_null($component_type) && !in_array($component_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'component_type', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['component_type'] = $component_type;

        return $this;
    }

    /**
     * Gets policy_violations
     *
     * @return \AmazonAdvertisingApi\Model\AsinPolicyViolation[]
     */
    public function getPolicyViolations()
    {
        return $this->container['policy_violations'];
    }

    /**
     * Sets policy_violations
     *
     * @param \AmazonAdvertisingApi\Model\AsinPolicyViolation[] $policy_violations A list of policy violations for the component that were detected during pre moderation. Note that this field is present in the response only when preModerationStatus is set to REJECTED.
     *
     * @return $this
     */
    public function setPolicyViolations($policy_violations)
    {
        $this->container['policy_violations'] = $policy_violations;

        return $this;
    }

    /**
     * Gets asin
     *
     * @return string
     */
    public function getAsin()
    {
        return $this->container['asin'];
    }

    /**
     * Sets asin
     *
     * @param string $asin Pre-moderated Asin Id.
     *
     * @return $this
     */
    public function setAsin($asin)
    {
        $this->container['asin'] = $asin;

        return $this;
    }

    /**
     * Gets id
     *
     * @return string
     */
    public function getId()
    {
        return $this->container['id'];
    }

    /**
     * Sets id
     *
     * @param string $id Id of the component. This is the same id sent as part of the request. This can be used to uniquely identify the component.
     *
     * @return $this
     */
    public function setId($id)
    {
        $this->container['id'] = $id;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    #[\ReturnTypeWillChange]
    public function offsetExists($offset)
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
    }

    /**
     * Sets value based on offset.
     *
     * @param integer $offset Offset
     * @param mixed   $value  Value to be set
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetSet($offset, $value)
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetUnset($offset)
    {
        unset($this->container[$offset]);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
            return json_encode(
                ObjectSerializer::sanitizeForSerialization($this),
                JSON_PRETTY_PRINT
            );
        }

        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}
